<%@page import="java.util.List"%>
<%@page import="com.libweb.model.dto.Book"%>
<%@page import="com.libweb.model.dto.Member"%>
<%@page import="com.libweb.model.dto.Rent"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>

<!DOCTYPE html>

<html>
<head>
	<meta charset="utf-8" />
    <title></title>
    <link rel="Stylesheet" href="/libweb/styles/default.css" />
</head>
<body>

    <div id="pageContainer">
    	
    	<!--  
    	<jsp:include page="/WEB-INF/views/include/header.jsp" />
        -->
        <!--  
        <%@ include file="/WEB-INF/views/include/header.jsp" %>
        -->
        
        <% pageContext.include("/WEB-INF/views/include/header.jsp"); %>
        
        
        <div id="content">
        	<br /><br />
        	<div style='text-align:center'>
        	
		    </div>
       		<br /><br />
       		<% Member member = (Member)session.getAttribute("loginuser"); %>
   	
        	<table border="1" align="center" width="700px">
        		<tr style="height:30px;background-color:orange">
        			<td>대여 번호</td>
		        	<% if(member.getMemberId().equals("admin")) {%>
				        <td>아이디</td>				    	    		          
		           	<% } %>        			
        			<td>도서 번호</td>
        			<td>제목</td>
        			<td>저자</td>
        			<td>출판사</td>
        			<td>대여일</td>
        			<td>반납일</td>
        			<td>반납 신청</td>
        			<td>상태</td>      			
        		</tr>

				<% List<Rent> rents = (List<Rent>)request.getAttribute("rents"); %>
				<% for (Rent rent : rents) { %>
        		<tr style="height:30px">
        			<td><%= rent.getRentNo() %></td>
        			<% if(member.getMemberId().equals("admin")) {%>
				    	<td><%= rent.getMemberId() %></td>				    	    		          
		           	<% } %>        			
        			<td><%= rent.getBookNo() %></td>
        			<td><%= rent.getBook().getTitle() %></td>
        			<td><%= rent.getBook().getAuthor() %></td>
        			<td><%= rent.getBook().getPublisher() %></td>
        			<td><%= rent.getRentDate() %></td>
        			<td><%= rent.getReverseDate() %></td>
        			<td>
	        			<% if(member.getMemberId().equals("admin")) { %>
	        				<% if(rent.getReverseReady().equals("request") || rent.getReverseReady().equals("reverse")) { %>
	        					[&nbsp;없음&nbsp;]
	        				<% } else { %>
	        					[&nbsp;<a href="/libweb/rent/reverseagree.action?rentno=<%=rent.getRentNo()%>&bookno=<%=rent.getBookNo()%>">반납 대기중</a>&nbsp;]
	        				<% } %>        			
	        			<% } else { %>
	        				<% if(rent.getReverseReady().equals("request")) { %>
	        					[&nbsp;<a href="/libweb/rent/reverserequest.action?rentno=<%=rent.getRentNo()%>&memberid=<%=member.getMemberId()%>">반납 신청 가능</a>&nbsp;]
	        				<% }else if(rent.getReverseReady().equals("reverse")) { %>
	        					[&nbsp;반납 완료&nbsp;]
	        				<% } else if(rent.getReverseReady().equals("onreverse")) { %>
	        					[&nbsp;반납 승인 대기중&nbsp;]
	        				<% } %>
	        			<% } %>
	        		</td>      			        			
        			<td>
        				<% if(member.getMemberId().equals("admin")) { %>
	        				<% if(rent.getStatus().equals("request")) { %>
	        						[&nbsp;<a href="/libweb/rent/rentagree.action?rentno=<%=rent.getRentNo()%>&bookno=<%=rent.getBookNo()%>">대여 승인</a>&nbsp;]
	        				<% } else if(rent.getStatus().equals("onrent")) { %>
	        					[&nbsp;대여 중&nbsp;]
	        				<% } else if(rent.getStatus().equals("reverse")) { %>
	        					[&nbsp;반납 완료&nbsp;]
	        				<% } else { %>
	        				    [&nbsp;연체중&nbsp;]
	        				<% } %>
	        			<% } else { %>
	        				<% if(rent.getStatus().equals("request")) { %>
	        					[&nbsp;대여 승인 대기중&nbsp;]
	        				<% }else if(rent.getStatus().equals("onrent")) { %>
	        					[&nbsp;대여중&nbsp;]
	        				<% } else if(rent.getStatus().equals("reverse")) { %>
	        					[&nbsp;반납 완료&nbsp;]
	        				<% } else {%>
	        					[&nbsp;연체 중&nbsp;]
	        				<% } %>
	        			<% } %>
	        		</td>       			
        		</tr>	
        		<% } %>
        	</table>        		 
        	 
        		
        		
        		
        		
        		
        		<%--
		            <% if(member.getMemberId().equals("admin")) {%>
		            <td><%	if(book.isStatusReady()) { %>
        					신청 있음
        				<%	}else { %>
        					신청 없음
        				<%	} %>
        			</td>	
		            <% }else { }%>         			
        			<td><%	if(book.isStatus()) { %>
        					대여 중
        				<%	}else { %>
        					대여 가능
        				<%	} %>
        			</td>
        			<td><%= book.getRegDate() %></td>
        		</tr>       
        		 --%> 		      	   	
        </div>
    </div>
</body>
</html>









